#include <iostream>

class Test
{
public:
    Test()
    {
        count++;
        std::cout<<"构造函数"<<std::endl;
    }

    ~Test()
    {
        count--;
        std::cout<<"析构函数"<<std::endl;
    }
public:
    static int count;
    int a;
};

//静态成员变量的初始化
int Test::count = 0;

int main()
{
    #if 0
    std::cout<<"静态:"<<Test::count<<std::endl;
    Test t1;
    t1.count = 20;
    std::cout<<"t1.c:"<<t1.count<<std::endl;

    Test t2;
    std::cout<<"t2.c:"<<t2.count<<std::endl;
    #endif

    Test *t1 = new Test();
    Test *t2 = new Test();

    delete t1;
    delete t2;

    //count = 0 无内存泄漏
    std::cout<<Test::count<<std::endl;

    return 0;
}